package org.fanximall.erp.product.application.convert;

import org.fanximall.erp.product.application.req.AttributeItemPageQuery;
import org.fanximall.erp.product.application.req.ConfAttributeSaveCommand;
import org.fanximall.erp.product.application.resp.AttributeDetailRespDTO;
import org.fanximall.erp.product.application.resp.AttributeItemRespDTO;
import org.fanximall.erp.product.domain.aggregate.AttributeAggregateRoot;
import org.fanximall.erp.product.domain.dto.AttributeItemPageQueryDTO;
import org.fanximall.erp.product.domain.model.AttributeItemModel;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * @author :  william
 * @version :  V1.0  created in 2024/4/23
 */
@Mapper(componentModel = "spring")
public interface AttributeConvert {


  @Mappings({
          @Mapping(source = "attrItemName", target = "attributeItemModel.attrItemName"),
          @Mapping(source = "attrType", target = "attributeItemModel.attrType"),
          @Mapping(source = "id",target ="attributeItemModel.id" ),
          @Mapping(source = "inputMode",target ="attributeItemModel.inputMode" ),
          @Mapping(source = "remark",target ="attributeItemModel.remark" ),
          @Mapping(source = "required",target ="attributeItemModel.required" ),
          @Mapping(source = "attrDescription",target ="attributeItemModel.attrDescription" ),
          @Mapping(source = "dataFormat",target ="attributeItemModel.dataFormat" ),
          @Mapping(source = "unit",target ="attributeItemModel.unit" ),
          @Mapping(source = "maxLength",target ="attributeItemModel.maxLength" ),
          @Mapping(source = "minLength",target ="attributeItemModel.minLength" ),
          @Mapping(source = "attributeValueSaveCommands",target ="attributeValueModel" )
  })
  AttributeAggregateRoot attributeItemCommentConvert(ConfAttributeSaveCommand confAttributeSaveCommand);


  AttributeItemPageQueryDTO attributeItemPageQueryConvert(AttributeItemPageQuery attributeItemPageQuery);


  List<AttributeItemRespDTO> attributeItemRespConvert(List<AttributeItemModel> attributeItemModels);

  @Mappings({
          @Mapping(source = "attributeItemModel", target = "attributeItemRespDTO"),
          @Mapping(source = "attributeValueModel", target = "attributeValueRespDTOS")
  })
  AttributeDetailRespDTO attributeDetailRespDTOConvert(AttributeAggregateRoot attributeAggregateRoot);
}
